package org.custom.spring.boot.datasource.exception.handler;

import org.custom.spring.boot.datasource.exception.TipException;
import org.custom.spring.boot.entity.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import static cn.hutool.core.text.CharSequenceUtil.EMPTY;

/**
 * 自定义异常拦截器
 *
 * @author 李坤
 * @date 2022/3/31 11:34
 */
@RestControllerAdvice
public class CustomExceptionHandler {
    @ExceptionHandler(TipException.class)
    public Result tipExceptionHandler(TipException tipException) {
        tipException.printStackTrace();
        return Result.fail(tipException.getMessage(), EMPTY);
    }
}
